<template>
  <a-card>
    <a-table
      :columns="columns"
      :row-key="(item) => item.id"
      :pagination="pagination"
      :data-source="dataSource"
      :loading="loading"
      @change="handleTableChange"
      bordered
    >
    </a-table>
  </a-card>
</template>

<script>
const columns = [
  {
    title: "序号",
    customRender: (text, record, index) => `${index + 1}`,
    align: "center",
    width: 150,
  },
  {
    title: "发生日期",
    dataIndex: "cureTime",
    align: "center",
    width: 250,
  },
  {
    title: "诊断结果",
    dataIndex: "cureResult",
    align: "center",
  },
  {
    title: "医嘱",
    dataIndex: "measures",
    align: "center",
  },
  {
    title: "备注",
    dataIndex: "remark",
    align: "center",
  },
  // {
  //   title: '操作',
  //   scopedSlots: { customRender: 'action' },
  // },
];

import { affairs } from "@/services";

export default {
  name: "cureList",

  data() {
    return {
      columns: columns,
      dataSource: [],
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0,
      },
      loading: false,
    };
  },

  mounted() {
    this.getDataSource(this.pagination);
  },

  methods: {
    // 获取数据
    getDataSource({ current, pageSize }) {
      this.loading = true;
      affairs.cureList({ pageNo: current, pageSize }).then((res) => {
        if (res.data.code == 200) {
          this.dataSource = res.data.data.content;
          this.pagination.total = res.data.data.totalElements;
          this.pagination.current = current;
          this.pagination.pageSize = pageSize;
          this.loading = false;
        } else {
          this.$message.error(res.data.msg);
        }
      });
    },

    // 分页切换
    handleTableChange(pagination) {
      console.log(pagination);
      this.getDataSource(pagination);
    },
  },
};
</script>

<style lang="less" scoped>
.search {
  margin-bottom: 54px;
}
.fold {
  width: calc(100% - 216px);
  display: inline-block;
}
.operator {
  margin-bottom: 18px;
}
@media screen and (max-width: 900px) {
  .fold {
    width: 100%;
  }
}
</style>
